﻿using Dsl.Ped.Framework.Converters;
using NUnit.Framework;

namespace DSLPedFrameworkTest.Converters
{
    [TestFixture]
    public class ObjectToLocalizedStringConverterTest
    {
        private ObjectToLocalizedStringConverter converter;

        private enum Test
        {
            A,
            B,
            C
        }

        private enum NonExistingEnum
        {
            A,
            B,
            C
        }

        [SetUp]
        public void SetUpForEachTest()
        {
            converter = new ObjectToLocalizedStringConverter();
        }

        [Test, Description("Convert string to localized string")]
        public void ConvertTest1()
        {
            var result = converter.Convert("VisualStudio", typeof(string), null, null);
            Assert.AreEqual("Visual Studio", result.ToString());
        }

        [Test, Description("Convert null to localized string")]
        public void ConvertTest2()
        {
            var result = converter.Convert(null, typeof(string), null, null);
            Assert.AreEqual(string.Empty, result.ToString());
        }

        [Test, Description("Convert enum to localized string")]
        public void ConvertTest3()
        {
            var result = converter.Convert(Test.A, typeof(Test), null, null);
            Assert.AreEqual("AAA", result.ToString());
        }

        [Test, Description("Convert enum which is not localized in the dictionary")]
        public void ConvertTest4()
        {
            var result = converter.Convert(NonExistingEnum.A, typeof(NonExistingEnum), null, null);
            Assert.AreEqual("A", result);
        }

        [Test]
        public void ConvertTest5()
        {
            var result = converter.Convert(null, typeof(Test), null, null);
            Assert.AreEqual(string.Empty, result);
        }

        [Test]
        public void ConvertTest6()
        {
            var result = converter.Convert(new ObjectToLocalizedStringConverterTest(),
                                           typeof (ObjectToLocalizedStringConverterTest), null, null);
            Assert.AreEqual(typeof(ObjectToLocalizedStringConverterTest).ToString(), result);
        }
    }
}
